﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Easyleave.Logic.Domain;

namespace Easyleave.WinformsTestClient
{
    public partial class NewLeaveForm : Form
    {
        LeaveWorkflowServiceClient wofkflowClient;
        public UserDto User { get; set; }
        public string[] Types { get; set; }
        public new MainForm Parent { get; set; }
        

        public NewLeaveForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            LeaveDto leaveDto = new LeaveDto();
            leaveDto.LeaveType = comboBox1.Text;
            leaveDto.FromDate = dateTimePicker1.Value;
            leaveDto.ToDate = dateTimePicker2.Value;
            wofkflowClient.SubmitNewLeaveRequest(User.Id, leaveDto);
            // refresh parent
            Parent.LoadMyLeaves();
            this.Hide();
        }

        private void NewLeaveForm_Load(object sender, EventArgs e)
        {
            wofkflowClient = new LeaveWorkflowServiceClient("WSHttpBinding_ILeaveWorkflowService");
            this.comboBox1.DataSource = Types;
        }
    }
}
